package br.com.androidblog;


import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.webkit.WebView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class itemBlog extends Activity {

	private String tituloNoticia; 
	private String url; 
	private String conteudo; 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		setContentView(R.layout.itemblog);

		TextView titulo = (TextView) findViewById(R.id.tituloblog);

		TextView web = (TextView) findViewById(R.id.web);

		Bundle bd = getIntent().getExtras();
		url = bd.getString("url");
		conteudo = bd.getString("conteudo");
		tituloNoticia = bd.getString("titulo");
		
		titulo.setText(tituloNoticia);

		web.setText(conteudo);// , "text/html", "UTF-8");

		
		LinearLayout layout = (LinearLayout) findViewById(R.id.publicidadeItemBlog);

		AdView adView = new AdView(this, AdSize.BANNER, "a14de7d2c14453a");

		layout.addView(adView);

		AdRequest request = new AdRequest();

		adView.loadAd(request);

	}


	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		menu.add(0,0,0,"Share");
		return true;
	}
	
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case 0:
			share(this.tituloNoticia, this.conteudo + " \n\nLink:"+this.url);
		}
		return false;
	}


	public void share(String subject, String text) {
		Intent intent = new Intent(Intent.ACTION_SEND);

		intent.setType("text/plain");
		intent.putExtra(Intent.EXTRA_SUBJECT, subject);
		intent.putExtra(Intent.EXTRA_TEXT, text);

		startActivity(intent);
	}
}
